package example.designpattern.fsm.transition;


import example.designpattern.fsm.state.AbstractState;

/**
 * 生成器模式完成状态转换类的构建，屏蔽内部的细节
 */
public abstract class StateTransitionBuilder {

  private AbstractState previousState;

  private AbstractState nextState;

  private TransitionFunction transitionFunction;

  public StateTransitionBuilder from(AbstractState from) {

    this.previousState = from;
    return this;
  }

  public StateTransitionBuilder to(AbstractState to) {

    this.nextState = to;
    return this;
  }

  public StateTransitionBuilder transition(TransitionFunction transitionFunction) {

    this.transitionFunction = transitionFunction;
    return this;
  }


  public abstract StateTransition build();

  public AbstractState getPreviousState() {

    return previousState;
  }

  public void setPreviousState(AbstractState previousState) {

    this.previousState = previousState;
  }

  public AbstractState getNextState() {

    return nextState;
  }

  public void setNextState(AbstractState nextState) {

    this.nextState = nextState;
  }

  public TransitionFunction getTransitionFunction() {

    return transitionFunction;
  }

  public void setTransitionFunction(TransitionFunction transitionFunction) {

    this.transitionFunction = transitionFunction;
  }

}